
/**
 * AppleIIGo
 * Mouse Interface Card class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "MouseInterfaceCard.h"

MouseInterfaceCard::MouseInterfaceCard(Motherboard * motherboard,
									   char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void MouseInterfaceCard::onMemoryRequested() {
	romMemoryOffset =
		motherboard->getMemory()->requestMemory(MOUSEINTERFACECARD_ROM_BYTENUM);
}

void MouseInterfaceCard::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Apple Mouse Interface Card ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
											  MOUSEINTERFACECARD_ROM_BYTENUM,
											  romImage);
}

void MouseInterfaceCard::writeIo(UINT16 address, UINT8 value) {
}

UINT8 MouseInterfaceCard::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 MouseInterfaceCard::readMemory(UINT16 address) {
	if (address & 0x800)
		return timingGenerator->readFloatingBus();
	else
		return romMemory[address & 0x7ff];
}
